//bange_console.hpp
//Copyright (C) 2010-2011 Oscar (.teri) Triano

//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.

#ifndef _bange_console_
#define _bange_console_

#include <iostream>
#include <string>
#include <deque>
#include <iterator>
#include <SFML/Graphics.hpp>

//#define DEBUG_ENTRY_DESTRUCTOR

namespace bange{
	
	class console{
		
		class entry: public sf::String{
			public:
				entry(const char *);
				#ifdef DEBUG_ENTRY_DESTRUCTOR
				~entry();
				#endif
				void MoveCursor(int);
				void AddChar(sf::Uint32);
				void RemoveChar();
				const char *GetString();
				sf::Vector2f GetCursorPosition();
			private:
				int icursor;
		};
		
		private:
			std::size_t fontsize;
			float dbentries;//distance between entries
			std::deque<bange::console::entry *> entries;
			std::deque<bange::console::entry *>::iterator currententry;
			sf::Shape background;
			sf::Shape cursor;
			float icursor;
		public:
			console();
			void Draw(sf::RenderWindow &);
			void MoveCursorThroughEntries(int);
			void MoveCursor(int);
			void AddChar(sf::Int32);
			void RemoveChar();
			void AddEntry(const char *);
			const char *GetString();
			~console();
		private:
			void ResetPositionEntries();
			void ResetPositionCursor();
		
	};
	
}

#endif
